
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;
public class Test1 {
    public static void main(String[] args) {
        LocalDateTime currentDate = LocalDateTime.now();

        LocalDateTime firstDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth());

        LocalDateTime lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth());

        System.out.println(firstDayOfMonth);
        System.out.println(lastDayOfMonth);



//        LocalDateTime currentDate = LocalDateTime.now();
//
//        //获取当前日期所在的当周周一
//        LocalDateTime firstDayOfWeek = currentDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
//        //获取当前日期所在的当周周日
//        LocalDateTime lastDayOfWeek = currentDate.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
//
//        System.out.println(firstDayOfWeek);
//        System.out.println(lastDayOfWeek);
//        LocalDateTime dateTime = LocalDateTime.now();
//        LocalDateTime newDatePlus = dateTime.plusDays(1);
//        System.out.println("增加1天后的日期："+newDatePlus);
//
//        LocalDateTime newDateMinus = dateTime.minusDays(1);
//        System.out.println("减少1天后的日期："+newDateMinus);
//
//        LocalDateTime dateTime1 = LocalDateTime.now();
//        LocalDateTime newDatePlus1 = dateTime1.plusWeeks(1);
//        System.out.println("增加1周后的日期："+newDatePlus1);
//
//        LocalDateTime newDateMinus1 = dateTime1.minusWeeks(1);
//        System.out.println("减少1周后的日期："+newDateMinus1);
//        LocalDateTime dateTime2 = LocalDateTime.now();
//        LocalDateTime newDatePlus2 = dateTime2.plusMonths(1);
//        System.out.println("增加1月后的日期："+newDatePlus2);
//
//        LocalDateTime newDateMinus2 = dateTime2.minusMonths(1);
//        System.out.println("减少1月后的日期："+newDateMinus2);
//        LocalDateTime dateTime3 = LocalDateTime.now();
//        LocalDateTime newDatePlus3 = dateTime.plusYears(1);
//        System.out.println("增加1年后的日期："+newDatePlus3);
//
//        LocalDateTime newDateMinus3 = dateTime.minusYears((1));
//        System.out.println("减少1年后的日期："+newDateMinus3);
//        LocalDateTime dateTime = LocalDateTime.of(2025,3,30,21,15);
//        LocalDateTime newDatePlus = dateTime.plusMonths(1);
//        System.out.println("增加1月后的日期："+newDatePlus);
//        LocalDateTime newDateMinus = dateTime.minusMonths(1);
//        System.out.println("减少1月后的日期："+newDateMinus);
//        LocalDateTime dateTime = LocalDateTime.now();
//        System.out.println("当前日期为: "+dateTime);//
//        System.out.println("本周周几："+dateTime.getDayOfWeek().getValue());
//        System.out.println("本月第几天："+dateTime.getDayOfMonth());
//        System.out.println("当年第几天："+dateTime.getDayOfYear());/**/
//        String stringDate = "2026-10-01 10:30:21";
//        //创建一个自定义的日期时间格式化器
//        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        LocalDateTime  date = LocalDateTime.parse(stringDate,dateTimeFormatter);
//        System.out.println("当前日期为: "+date);
//        LocalDateTime localDateTime = LocalDateTime.now();
//        int year = localDateTime.getYear();
//
//        int monthValue = localDateTime.getMonthValue();
//
//        System.out.println("year:" + year);
//        System.out.println("monthValue:" + monthValue);
//
//
//        int day = localDateTime.getDayOfMonth();
//        System.out.println("day:" + day);
//        //A of B   -> B的A
//        day = localDateTime.getDayOfYear();
//        System.out.println("day:" + day);
//
//        int hour = localDateTime.getHour();
//
//        int minute = localDateTime.getMinute();
//
//        int second = localDateTime.getSecond();
//        LocalDateTime localDateTime1 = LocalDateTime.now();
//
//        LocalDateTime localDateTime2 = LocalDateTime.of(2025,3,26,21,20);
//
//        LocalDateTime parsed = LocalDateTime.parse("2026-05-15T10:30:00");//这个将字符串转化
//
//        System.out.println(localDateTime1);
//        System.out.println(localDateTime2);
//        System.out.println(parsed);









//        Date date = new Date(123,9,8);
//      System.out.println(date);
//
//        Date date1 = new Date();
//        System.out.println(date1);
    }
}
